package main.dao;

import java.util.List;

import javax.annotation.Resource;

import main.entity.ReplyVO;

import org.hibernate.Query;
import org.hibernate.SessionFactory;
import org.springframework.stereotype.Repository;

@SuppressWarnings("unchecked")
@Repository("replyDAO")
public class ReplyDAO extends BaseDAO<ReplyVO>{
	
	@Resource(name="sessionFactory")
	private SessionFactory sessionFactory;
	
	public List<?> getReplyByThreadsID(Integer threadsID){
//		Configuration configuration = new Configuration().configure();
//		StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties());
//		StandardServiceRegistryImpl registry = (StandardServiceRegistryImpl) builder.build();
//		SessionFactory sessionFactory = configuration.buildSessionFactory(registry);

		String queryString = "from main.entity.ReplyVO as rpl where rpl.threads_ID="+threadsID;
//		Session session = sessionFactory.getCurrentSession();
//		Transaction tx = session.beginTransaction();
		 
		Query query = sessionFactory.openSession().createQuery(queryString);
//		query.setParameter("ID", threadsID);
		return query.list();
//		List<?> list = getHibernateTemplate().find(queryString);
//		return list;
	}
	
}
